"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
let Department = class Department {
    constructor() {
        this.id = 0;
        this.name = '';
    }
};
Department = __decorate([
    (0, index_1.Entity)("department_info")
], Department);
let User = class User {
    constructor() {
        this.id = 0;
        this.name = '';
        this.age = 0;
        this.department_id = 0;
        this.department = {};
    }
};
__decorate([
    (0, index_1.Parent)({ parentClass: Department, parentId: 'department_id' })
], User.prototype, "department", void 0);
User = __decorate([
    (0, index_1.Entity)("user_info")
], User);
let postgresql = new index_1.MySql({
    "host": "192.168.1.52",
    "port": 5306,
    "database": "test_zh",
    "user": "root",
    "password": "Jimmy007",
    connectionLimit: 10
});
postgresql.connect().then(async () => {
    const entityDynamicQuery = new index_1.EntityDynamicQuery(postgresql, User, { enableSqlLog: true });
    let user = new User();
    user.name = 'zhang san';
    user.age = 10;
    user.department_id = 1;
    user = (await entityDynamicQuery.save(user));
    console.log(user);
    console.log(await entityDynamicQuery.findAll({}));
    console.log(await entityDynamicQuery.findOne({}));
    console.log(await entityDynamicQuery.navigationFindOne({}));
});
